
import os
import numpy as np
import matplotlib.pyplot as plt


valus = []
data = open('new_port_bytes.txt')
for each_data in data:
    (time,value) = each_data.split(',')
    time = time.replace("{","")
    value = value.replace("}","")
    # 取比特值
    value = value.split(':')[1]
    # 去除\n
    value = value.replace("\n","")
    # 去除空格

    # print(time)    value = value.replace(" ","")
    # print()
    # print(value)
    v = round(int(value)/1000/1000)
    valus.append(v)

data.close()

print(valus)

x_value = valus
# y_value = []
lenth = len(valus)
print(lenth)
# for i in range(lenth):
#     y_value.append(10)
# print(y_value)

index = np.arange(lenth)

# index = 10
plt.bar(left=index, height=x_value, color='gray', width=0.5)

plt.show()
# plt.show()